<!DOCTYPE html>
<html>
<head>
    

    

    



    <meta charset="utf-8">
    
    
    <link rel="canonical" href="http://xiejm.com/Python/Python-Base.html">
    
    
    <title>Python 基础 | XieJM&#39;s Blog | 建立博客是为了记录工作经验以及生活点滴,也是将知识和经验分享给需要的朋友，希望对你有帮助！</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#00bcd4">
    
    
    <meta name="keywords" content="Python">
    <meta name="description" content="Python 基础：定义函数、常用数据结构、条件判断语句、for循环、字符串处理、异常处理、模块引入">
<meta name="keywords" content="Python">
<meta property="og:type" content="article">
<meta property="og:title" content="Python 基础">
<meta property="og:url" content="http://xiejm.com/Python/Python-Base.html">
<meta property="og:site_name" content="XieJM&#39;s Blog">
<meta property="og:description" content="Python 基础：定义函数、常用数据结构、条件判断语句、for循环、字符串处理、异常处理、模块引入">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2017-09-14T02:04:15.048Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Python 基础">
<meta name="twitter:description" content="Python 基础：定义函数、常用数据结构、条件判断语句、for循环、字符串处理、异常处理、模块引入">
    
        <link rel="alternate" type="application/atom+xml" title="XieJM&#39;s Blog" href="/atom.xml">
    
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" href="/css/style.css?v=1.6.13">
    <script>window.lazyScripts=[]</script>

    <!-- custom head -->
    

</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide" >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/img/brand.jpg)">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">XieJM</h5>
          <a href="mailto:309469843@qq.com" title="309469843@qq.com" class="mail">309469843@qq.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/index.html"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives/index.html"  >
                <i class="icon icon-lg icon-archives"></i>
                归档
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags/index.html"  >
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/categories/index.html"  >
                <i class="icon icon-lg icon-th-list"></i>
                分类
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/xjmhz" target="_blank" >
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
      </ul>      
    </div>
    <footer class="footer">
    <p>欢迎加入我们的大数据交流群：<br>群1：258669058 群2：126181630</p>   
    <p>        
        <span><a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh"><img src="/img/cc.png"></a></span>
        
        <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-2x icon-rss-square"></i></a></span>
        
    </p>
    <p><span>XieJM &copy; 2017</span>
    </p>
    <p><span>
            
            Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a>
        </span>
    </p>
</footer>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">Python 基础</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">Python 基础</h1>
        <h5 class="subtitle">
            
                <time datetime="2017-08-31T00:35:50.142Z" itemprop="datePublished" class="page-time">
  2017-08-31
</time>


	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/tech/">技术</a></li></ul>

            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#1-定义函数："><span class="post-toc-text">1. 定义函数：</span></a></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#2-常用数据结构"><span class="post-toc-text">2.常用数据结构</span></a></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#3-条件判断语句"><span class="post-toc-text">3.条件判断语句</span></a></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#4-for循环"><span class="post-toc-text">4.for循环</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#4-字符串处理"><span class="post-toc-text">4.字符串处理</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#5-异常处理"><span class="post-toc-text">5.异常处理</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#6-模块引入"><span class="post-toc-text">6.模块引入</span></a></li></ol></li></ol>
        </nav>
    </aside>
    
<article id="post-Python/Python-Base"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">Python 基础</h1>
        <div class="post-meta">
            <time class="post-time" title="2017-08-31 08:35:50" datetime="2017-08-31T00:35:50.142Z"  itemprop="datePublished">2017-08-31</time>

            
	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/tech/">技术</a></li></ul>



            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <p>Python 基础：定义函数、常用数据结构、条件判断语句、for循环、字符串处理、异常处理、模块引入<br><a id="more"></a></p>
<h1 id="1-定义函数："><a href="#1-定义函数：" class="headerlink" title="1. 定义函数："></a>1. 定义函数：</h1><figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line"><span class="comment">#!/usr/bin/python</span></div><div class="line"></div><div class="line"><span class="comment">#函数定义格式：def 函数名(参数)</span></div><div class="line"><span class="function"><span class="keyword">def</span> <span class="title">print_your_name</span><span class="params">(name)</span>:</span></div><div class="line">    <span class="keyword">print</span> <span class="string">"badou hadoop study!, your name"</span>, name</div><div class="line">    <span class="keyword">return</span> (<span class="string">"%s, is good student"</span> % name)</div><div class="line"></div><div class="line"><span class="comment">#函数调用格式： 函数名(参数)</span></div><div class="line"><span class="keyword">print</span> <span class="string">'================='</span></div><div class="line"><span class="keyword">print</span> print_your_name(<span class="string">'zhangsan'</span>)</div><div class="line"><span class="keyword">print</span> <span class="string">'================='</span></div><div class="line"><span class="keyword">print</span> print_your_name(<span class="string">'lisi'</span>)</div><div class="line"><span class="keyword">print</span> <span class="string">'================='</span></div></pre></td></tr></table></figure>
<hr>
<h1 id="2-常用数据结构"><a href="#2-常用数据结构" class="headerlink" title="2.常用数据结构"></a>2.常用数据结构</h1><p>哈希表：hashmap,数组：array,集合：set</p>
<p>python中：</p>
<ul>
<li>hashmap -&gt; dict</li>
<li>array -&gt; list</li>
<li>set -&gt; set</li>
</ul>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line"><span class="comment">#字典代码演示</span></div><div class="line"><span class="comment">#dict</span></div><div class="line"> color = &#123;<span class="string">"red"</span>:<span class="number">0.2</span>,<span class="string">"green"</span>:<span class="number">0.4</span>,<span class="string">"blue"</span>:<span class="number">0.4</span>&#125;</div><div class="line"> </div><div class="line"> <span class="keyword">print</span> color [<span class="string">'red'</span>]</div><div class="line"> <span class="keyword">print</span> color [<span class="string">'green'</span>]</div><div class="line"> </div><div class="line"> <span class="comment">#输出结果</span></div><div class="line"> <span class="number">0.2</span></div><div class="line"> <span class="number">0.4</span></div></pre></td></tr></table></figure>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="comment">#数组代码演示</span></div><div class="line"><span class="comment">#list</span></div><div class="line">color_list = [<span class="string">'red'</span>,<span class="string">'blue'</span>,<span class="string">'green'</span>,<span class="string">'yellow'</span>]</div><div class="line"><span class="keyword">print</span> color_list[<span class="number">2</span>]</div><div class="line"></div><div class="line"><span class="comment">#输出结果</span></div><div class="line">blue</div></pre></td></tr></table></figure>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line"><span class="comment">#集合代码演示</span></div><div class="line"><span class="comment">#set</span></div><div class="line"><span class="comment">#使用前需声明</span></div><div class="line">a_set = set()</div><div class="line">a_set.add(<span class="string">'111'</span>)</div><div class="line">a_set.add(<span class="string">'222'</span>)</div><div class="line">a_set.add(<span class="string">'333'</span>)</div><div class="line">a_set.add(<span class="string">'111'</span>)</div><div class="line"></div><div class="line"><span class="keyword">print</span> a_set</div><div class="line"></div><div class="line"><span class="comment">#输出结果</span></div><div class="line">set([<span class="string">'111'</span>,<span class="string">'222'</span>,<span class="string">'333'</span>])</div><div class="line"></div><div class="line"><span class="comment">#set()的特性：在元素内不会出现重复元素</span></div></pre></td></tr></table></figure>
<hr>
<h1 id="3-条件判断语句"><a href="#3-条件判断语句" class="headerlink" title="3.条件判断语句"></a>3.条件判断语句</h1><figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line"><span class="comment">#if</span></div><div class="line"></div><div class="line">a=<span class="number">1</span></div><div class="line"><span class="keyword">if</span> a &gt; <span class="number">0</span>:</div><div class="line">    <span class="keyword">print</span> <span class="string">'a gt 0'</span></div><div class="line"><span class="keyword">elif</span> a == <span class="number">0</span>:</div><div class="line">    <span class="keyword">print</span> <span class="string">'a eq 0'</span></div><div class="line"><span class="keyword">else</span>:</div><div class="line">    <span class="keyword">print</span> <span class="string">'a lt 0'</span></div><div class="line">    </div><div class="line"><span class="comment"># gt: 大于，greater than缩写</span></div><div class="line"><span class="comment"># eq: 等于，equality 缩写</span></div><div class="line"><span class="comment"># lt: 小于，less-than 缩写</span></div></pre></td></tr></table></figure>
<hr>
<h1 id="4-for循环"><a href="#4-for循环" class="headerlink" title="4.for循环"></a>4.for循环</h1><figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div></pre></td><td class="code"><pre><div class="line"><span class="comment">#for</span></div><div class="line"></div><div class="line"><span class="comment">#数组</span></div><div class="line">a_list = []</div><div class="line">a_list.append[<span class="string">'111'</span>]</div><div class="line">a_list.append[<span class="string">'222'</span>]</div><div class="line">a_list.append[<span class="string">'333'</span>]</div><div class="line">a_list.append[<span class="string">'444'</span>]</div><div class="line"></div><div class="line"><span class="keyword">for</span> value <span class="keyword">in</span> a_list:</div><div class="line">    <span class="keyword">print</span> value</div><div class="line">    </div><div class="line"><span class="comment">#输出结果</span></div><div class="line"><span class="number">111</span></div><div class="line"><span class="number">222</span></div><div class="line"><span class="number">333</span></div><div class="line"><span class="number">444</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">#集合 set</span></div><div class="line">a_set = set()</div><div class="line">a_set.add(<span class="string">'a'</span>)</div><div class="line">a_set.add(<span class="string">'b'</span>)</div><div class="line">a_set.add(<span class="string">'d'</span>)</div><div class="line">a_set.add(<span class="string">'d'</span>)</div><div class="line">a_set.add(<span class="string">'e'</span>)</div><div class="line"></div><div class="line"><span class="keyword">for</span> value <span class="keyword">in</span> a_set:</div><div class="line">    <span class="keyword">print</span> value</div><div class="line">    </div><div class="line"><span class="comment">#输出结果： set内部通过hash排序，所以输出顺序与追加的item顺序不一致</span></div><div class="line"></div><div class="line">a</div><div class="line">c</div><div class="line">b</div><div class="line">e</div><div class="line">d</div><div class="line"></div><div class="line"><span class="comment">#字典 dict</span></div><div class="line">b_dict = &#123;&#125;</div><div class="line">b_dict[<span class="string">'aaa'</span>] = <span class="number">1</span></div><div class="line">b_dict[<span class="string">'bbb'</span>] = <span class="number">2</span></div><div class="line">b_dict[<span class="string">'ccc'</span>] = <span class="number">3</span></div><div class="line">b_dict[<span class="string">'ddd'</span>] = <span class="number">4</span></div><div class="line">b_dict[<span class="string">'eee'</span>] = <span class="number">5</span></div><div class="line"></div><div class="line"><span class="comment">#字段 读取需要用到key,value</span></div><div class="line"><span class="keyword">for</span> key, value int b_dict.items():</div><div class="line">    <span class="keyword">print</span> key + <span class="string">" ===&gt;"</span> + str(value)</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">#输出结果 :字典内部顺序通过hashmap排序</span></div><div class="line">eee ===&gt; 5</div><div class="line">aaa ===&gt; 1</div><div class="line">bbb ===&gt; 2</div><div class="line">ccc ===&gt; 3</div><div class="line">ddd ===&gt; 4</div><div class="line"></div><div class="line"></div><div class="line">sum = <span class="number">0</span></div><div class="line"><span class="keyword">for</span> value <span class="keyword">in</span> range(<span class="number">1</span>,<span class="number">11</span>):</div><div class="line">    sum += value</div><div class="line"><span class="keyword">print</span> sum</div></pre></td></tr></table></figure>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line"><span class="comment">#while</span></div><div class="line"></div><div class="line">cnt = <span class="number">2</span></div><div class="line"><span class="keyword">while</span> cnt &gt; <span class="number">0</span>:</div><div class="line">    <span class="keyword">print</span> <span class="string">'i love python'</span></div><div class="line">    cnt -= <span class="number">1</span></div><div class="line"></div><div class="line"><span class="comment"># print dual</span></div><div class="line">i = <span class="number">1</span></div><div class="line"><span class="keyword">while</span> i &lt; <span class="number">10</span>:</div><div class="line">    i += <span class="number">1</span></div><div class="line">    <span class="keyword">if</span> i % <span class="number">2</span> &gt; <span class="number">0</span>:</div><div class="line">	<span class="keyword">continue</span> </div><div class="line">    <span class="keyword">print</span> i</div></pre></td></tr></table></figure>
<hr>
<h2 id="4-字符串处理"><a href="#4-字符串处理" class="headerlink" title="4.字符串处理"></a>4.字符串处理</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line"><span class="comment">#string</span></div><div class="line"></div><div class="line">str = <span class="string">'qwert'</span></div><div class="line"><span class="keyword">print</span> len(str)</div><div class="line"></div><div class="line"><span class="comment">#输出第二到第五个字符</span></div><div class="line"><span class="comment">#string 取字符</span></div><div class="line"><span class="keyword">print</span> str[<span class="number">2</span>:<span class="number">5</span>]</div><div class="line"></div><div class="line">str <span class="string">'AbcDEf'</span></div><div class="line"><span class="comment">#全部字符转换为小写</span></div><div class="line"><span class="keyword">print</span> str.lower()</div></pre></td></tr></table></figure>
<hr>
<h2 id="5-异常处理"><a href="#5-异常处理" class="headerlink" title="5.异常处理"></a>5.异常处理</h2><hr>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="comment">#exception</span></div><div class="line"></div><div class="line"><span class="comment">#try... catch</span></div><div class="line"></div><div class="line"><span class="comment">#try:</span></div><div class="line">a=<span class="number">6</span></div><div class="line">b=a/<span class="number">0</span></div><div class="line">exception Exception e:</div><div class="line">    <span class="keyword">print</span> Exception,<span class="string">":"</span> e</div></pre></td></tr></table></figure>
<hr>
<h2 id="6-模块引入"><a href="#6-模块引入" class="headerlink" title="6.模块引入"></a>6.模块引入</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">import</span> math <span class="comment">#引入模块</span></div><div class="line"></div><div class="line"><span class="keyword">print</span> math.pow(<span class="number">2</span>,<span class="number">3</span>)</div><div class="line"><span class="keyword">print</span> round(<span class="number">4</span>,<span class="number">9</span>)</div><div class="line"></div><div class="line"><span class="keyword">import</span> random</div><div class="line">item = [<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>]</div><div class="line">random.shuffle(items)</div><div class="line"><span class="keyword">print</span> items</div><div class="line"></div><div class="line">a = random.randint(<span class="number">1</span>,<span class="number">3</span>)</div><div class="line"><span class="keyword">print</span> a</div><div class="line"></div><div class="line"></div><div class="line">s_list = random.sample(<span class="string">'abcdefg'</span>,<span class="number">3</span>)</div><div class="line"><span class="keyword">print</span> s_list</div></pre></td></tr></table></figure>

        </div>

        <blockquote class="post-copyright">
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2017-09-14T02:04:15.048Z" itemprop="dateUpdated">2017-09-14 10:04:15</time>
</span><br>


        
        原始链接：<a href="/Python/Python-Base.html" target="_blank" rel="external">http://xiejm.com/Python/Python-Base.html</a>
        
    </div>
    <footer>
        <a href="http://xiejm.com">
            <img src="/img/avatar.jpg" alt="XieJM">
            XieJM
        </a>
    </footer>
</blockquote>

        


        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Python/">Python</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://xiejm.com/Python/Python-Base.html&title=《Python 基础》 — XieJM's Blog&pic=http://xiejm.com/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://xiejm.com/Python/Python-Base.html&title=《Python 基础》 — XieJM's Blog&source=Python 基础：定义函数、常用数据结构、条件判断语句、for循环、字符串处理、异常处理、模块引入" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://xiejm.com/Python/Python-Base.html" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《Python 基础》 — XieJM's Blog&url=http://xiejm.com/Python/Python-Base.html&via=http://xiejm.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://xiejm.com/Python/Python-Base.html" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/Linux/Change_CentOS_yum_repo_to_aliyun.html" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">将CentOS的yum源更换为国内的阿里云源</h4>
      </a>
    </div>
  

  
</nav>



    


<section class="comments" id="comments">
    <div id="disqus_thread"></div>
    <script>
    var disqus_shortname = 'true';
    lazyScripts.push('//' + disqus_shortname + '.disqus.com/embed.js')
    </script>
    <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</section>













</article>



</div>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://xiejm.com/Python/Python-Base.html&title=《Python 基础》 — XieJM's Blog&pic=http://xiejm.com/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://xiejm.com/Python/Python-Base.html&title=《Python 基础》 — XieJM's Blog&source=Python 基础：定义函数、常用数据结构、条件判断语句、for循环、字符串处理、异常处理、模块引入" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://xiejm.com/Python/Python-Base.html" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《Python 基础》 — XieJM's Blog&url=http://xiejm.com/Python/Python-Base.html&via=http://xiejm.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://xiejm.com/Python/Python-Base.html" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: false };


</script>

<script src="/js/main.min.js?v=1.6.13"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="/js/search.min.js?v=1.6.13" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>



<script>
(function() {
    var OriginTitile = document.title, titleTime;
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            document.title = 'XieJM's Blog';
            clearTimeout(titleTime);
        } else {
            document.title = 'XieJM's Blog';
            titleTime = setTimeout(function() {
                document.title = OriginTitile;
            },2000);
        }
    });
})();
</script>



</body>
</html>
